<template>
  <view class="apps">
	  <view class="mt20 plr20 ptb20 bgwhite" v-if="item">
		  <view class="flex ptb10 aic">
		  	<view class="f1 flex f13">{{item.stadium.name}}</view>
		  	<view>
		  		<text class="f13" v-if="item.state == 1">已预定</text>
		  		<text class="f13" v-if="item.state == 2">需现场确认</text>
		  		<text class="f13" v-if="item.state == 3">待核销</text>
		  		<text class="f13" v-if="item.state == 4">已核销</text>
		  	</view>
		  </view>
		  <uv-line></uv-line>
		  <view class="flex ptb20 aic jcsb">
		  	<view class="fl flex f13 c999">预约类型</view>
		  	<view class="f14 c666">
		  		<text v-if="item.type == 1">线上跟约</text>
		  		<text v-else>场馆预定</text>
		  	</view>
		  </view>
		  <view class="flex ptb20 aic jcsb">
		  	<view class="fl flex f13 c999">预约场地</view>
		  	<view class="f14 c666">
		  		<text>{{item.stadium.name}}</text>
		  	</view>
		  </view>
		  <view class="flex ptb20 aic jcsb">
		  	<view class="fl flex f13 c999">预约日期</view>
		  	<view class="f14 c666">
		  		<text>{{item.year}}-{{item.month}}-{{item.days}}</text>
		  	</view>
		  </view>
		  <view class="flex ptb20 aic jcsb">
		  	<view class="fl flex f13 c999">预约时间</view>
		  	<view class="f14 c666">
		  		<text>{{parseInt(item.hour)}}:00 ~ {{parseInt(item.hour)+1}}:00</text>
		  	</view>
		  </view>
		  <uv-line></uv-line>
		  <view class="flex ptb20 aic jcc" v-if="item.state == 3">
		  	<uv-button  size="large" type="error" text="出示入场二维码"  @click="qrcode"></uv-button>
		  </view>
		  
		  <view class="flex ptb20 aic jcsb jcc" v-if="(item.state ==3 || item.state ==2 || item.state ==1) && item.subscribe_type == 1">
			<uv-button size="large" type="error" text="分享邀约朋友" open-type="share"></uv-button>
		  </view>
		
	  </view>
	  <uv-popup ref="popup" :close-on-click-overlay="false" :closeable="true">
		  <view class="plr20">
			<view style="width: 600rpx;padding-top: 50px; background-color: #fff;display: flex; align-items: center; justify-content: center;">
				<uv-qrcode ref="qrcode" size="600rpx" :value="qrcodeTxt" :start="false"></uv-qrcode>
			</view>
			<view class="ptb20 flex aic jcc fdc">
				<view class="f14 black">{{item.stadium.name}}</view>
				<view class="f14 black">{{item.year}}-{{item.month}}-{{item.days}} {{item.hour}}:00</view>
			</view>
		  </view>
		</uv-popup>
  </view>
</template>
<script>
	import { util } from '/common/util.js';
	import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js'
	let app;
	export default {
	  data() {
		return {
		  id:0,
		  item:{},
		  titleList:[
			  '【紧急呼叫羽毛球搭子】融合体育球场，打羽毛球！缺人速来！',
			  '「羽」你相约,周末不宅，球场见！羽毛球局已组好，缺你不可！',
			  '「打球不积极，思想有问题！快来组队拯救我的球技」',
			  '谁「羽」争锋！融合体育球场，求虐～',
			  '「听说打羽毛球能瘦？快来一起验证真理！」'
		  ],
		  qrcodeTxt:"",
		  
		}
	  },
	  onLoad(opt) {
		app = this;
		this.id = opt.id;
		this.getList();
	  },
	  onShow(){
		  this.getList();
	  },

	  onShareAppMessage() {
	  		  const rdn = Math.round(Math.random() * (5 - 1)) + 1;
	      return {
	  			title: this.titleList[rdn-1],
	  			path: '/pages/order/share?id='+this.item.order_id,
	  			imageUrl:'https://ball.lifecloud.top/static/m.jpg'
	  		  }
	  },
	  methods: {
		async getList(){
			const data = await util.request({
				url:'/subscribe/detail',
				data:{id:this.id}
			});
			if(data.code == '200'){
				this.item = data.data;
				
			}
		},
		async qrcode(){
			const data = await util.request({
				url:'/subscribe/qrcode',
				data:{id:this.id},
			});
			if(data.code == '200'){
				this.qrcodeTxt = data.data;
				this.$refs.popup.open();
			}else{
				this.getList();
				util.alert(data.msg);
			}
		}
	  }
	}
</script>
<style lang="scss" scoped>
	.fixd{position: fixed; bottom:0;left:0;right:0;}
</style>

